import React from "react";
import store from '../store'
export default class Demo2 extends React.Component {
    constructor(prop) {
        super(prop);
        this.state = {
            data: []
        }
    }

    getData() {
        const data = store.getState()
        this.setState({ data })
    }

    render() {
        return (
            <div>
                <h1>Demo2</h1>
                <button onClick={this.getData.bind(this)}>获取</button>

                <ul>
                    {
                        this.state.data.map((item, index) => {
                            return <li key={index}>{item.name}</li>
                        })
                    }
                </ul>
            </div>
        )
    }
}